from wormbane.model.feature import Door, Corridor
from wormbane.util.random_ import percent_chance

def command_search(game):
    game.write(game.hero, 'searches')
    game.hero_moved = True
    for cell in game.hero.env.neighbors:
        if cell.feature.is_wall and cell.feature.secret and percent_chance(50):
            if cell.feature.axis:
                Door(axis = cell.feature.axis).move_to(cell)
            else:
                Corridor().move_to(cell)
            game.write(game.hero, 'finds', cell.feature)
